using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class DataListNextPrevious : System.Web.UI.Page
{
    int pageSize = 9;
    ControlProviders controlProviders;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            lblPage.Text = "1";
            controlProviders = new ControlProviders();
            controlProviders.FillRecruiterAccount(this.DataList1, 1, pageSize);
            linkPrevious.Visible = false;
        }
    }
    

  
    protected void linkPrevious_Click(object sender, EventArgs e)
    {
        linkNext.Visible = true;
        int currentPage = Convert.ToInt32(lblPage.Text);
        if (currentPage > 1) currentPage--;
        controlProviders = new ControlProviders();
        controlProviders.FillRecruiterAccount(this.DataList1, 
        (currentPage - 1) * pageSize + 1, pageSize);
        lblPage.Text = currentPage.ToString();
        if(currentPage==1)
            linkPrevious.Visible = false;
        else
            linkPrevious.Visible = true;  
            
    }

    protected void linkNext_Click(object sender, EventArgs e)
    {
        linkPrevious.Visible = true;  
        int currentPage = Convert.ToInt32(lblPage.Text);
        if (currentPage > 0) currentPage++;
        controlProviders = new ControlProviders();

        if (controlProviders.FillRecruiterAccount(this.DataList1, (currentPage - 1) * pageSize + 1, pageSize) < pageSize)
            linkNext.Visible=false;
        else
            linkNext.Visible = true;
        lblPage.Text = currentPage.ToString();
    }
}
